<!DOCTYPE html>
<html>
	<head>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1" />
		<meta charset="UTF-8">
		<title>会场列表</title>
		<script type="text/javascript" src="__TMPL__/public/assets/js/flexible.js" ></script>
		<link rel="stylesheet" href="__TMPL__/public/assets/css/all_page.css" />
		<link rel="stylesheet" href="__TMPL__/public/assets/css/public.css" />
		<link rel="stylesheet" href="__TMPL__/public/assets/css/mobiscroll.css" />
		<link rel="stylesheet" href="__TMPL__/public/assets/css/mobiscroll_002.css" />
		<link rel="stylesheet" href="__TMPL__/public/assets/css/mobiscroll_003.css" />
		<style>
			
		</style>
	</head>
	<body>
		
		<div class="room">
			<!--头部-->
			<div class="pTop">
				<label>时间：</label>
				<div class="input">
					<input value="{:date('Y-m-d')}" class="" readonly="readonly" name="appDate" id="appDate" type="text">
					<php>$arr = array("日","一","二","三","四","五","六");</php>
					<p id="appDateText">{:date('m-d')}<span>周{:$arr[date('w')]}</span></p>
				</div> <span>-</span>
				<div class="input">
					<input value="" class="" readonly="readonly" name="appDate" id="amOrpm" type="text">
					<p id="amOrpmText">
					<if condition="$timetype eq 1">
							上午
							<else/>
							下午
						</if></p>
				</div>
				<ul id="sex-list" style="display: none">
					<li>上午</li>
					<li>下午</li>
				</ul>
			</div>
			
			<!--会议室列表-->
			<div class="rCn div_float">
				<foreach name="info" item="vo" key="k">
				
				<div class="rList div_float">
					<if condition="$k%3==0 || $k eq 0">
						<img src="__TMPL__/public/assets/images/y1.png" />
						<elseif condition="($k+2)%3==0"/>
						<img src="__TMPL__/public/assets/images/y2.png" />
						<elseif condition="($k+1)%3==0"/>
						<img src="__TMPL__/public/assets/images/y3.png" />
					</if>
					<P>{$vo['list_title']}</P>
					<P>（{$vo['list_subtitle']}）</P>
					<if condition="$vo['book']['status'] === 1">
					<P class="state audit">已预约</P>
					<p class="yd noYd">预定</p>
					<elseif condition="$vo['book']['status'] === 0"/>
					<P class="state audit">待审核</P>
					<p class="yd noYd">预定</p>
					<else/>
					<P class="state">未预约</P>
					<a href="{:url('add',array('id'=>$vo['id'],'timetype'=>$timetype,'sdate'=>date('Y-m-d')))}"><p class="yd">预定</p></a>
					</if>
					
				</div>
				</foreach>
				<!-- <div class="rList div_float">
					<img src="__STATIC__/meeting/img/y2.png" />
					<P>海珠会议文化中心</P>
					<P>（带主席台）</P>
					<P class="state audit">待审核 </P>
					<p class="yd noYd">预定</p>
				</div>
				<div class="rList div_float">
					<img src="__STATIC__/meeting/img/y3.png" />
					<P>海珠会议文化中心</P>
					<P>（带主席台）</P>
					<P class="state">待审核 </P>
					<p class="yd">预定</p>
				</div>
				<div class="rList div_float">
					<img src="__STATIC__/meeting/img/y1.png" />
					<P>海珠会议文化中心</P>
					<P>（带主席台）</P>
					<P class="state">待审核 </P>
					<p class="yd">预定</p>
				</div>
				<div class="rList div_float">
					<img src="__STATIC__/meeting/img/y2.png" />
					<P>海珠会议文化中心</P>
					<P>（带主席台）</P>
					<P class="state">待审核 </P>
					<p class="yd">预定</p>
				</div>
				<div class="rList div_float">
					<img src="__STATIC__/meeting/img/y3.png" />
					<P>海珠会议文化中心</P>
					<P>（带主席台）</P>
					<P class="state">待审核 </P>
					<p class="yd">预定</p>
				</div>
				<div class="rList div_float">
					<img src="__STATIC__/meeting/img/y1.png" />
					<P>海珠会议文化中心</P>
					<P>（带主席台）</P>
					<P class="state">待审核 </P>
					<p class="yd">预定</p>
				</div>
				<div class="rList div_float">
					<img src="__STATIC__/meeting/img/y2.png" />
					<P>海珠会议文化中心</P>
					<P>（带主席台）</P>
					<P class="state">待审核 </P>
					<p class="yd">预定</p>
				</div>
				<div class="rList div_float">
					<img src="__STATIC__/meeting/img/y3.png" />
					<P>海珠会议文化中心</P>
					<P>（带主席台）</P>
					<P class="state">待审核 </P>
					<p class="yd">预定</p>
				</div> -->
			</div>
			
			<!--我的预定-->
			<div class="meYd">
				<a href="{:url('book')}">
				<p>我的预定</p>
				</a>
			</div>
			
			<!--公共底部-->
			<include file='public@footer'/>
			
		</div>
		
	
	<script type="text/javascript" src="__TMPL__/public/assets/js/jquery-1.8.3.js" ></script>
	<script type="text/javascript" src="__TMPL__/public/assets/js/mobiscroll.custom-2.5.2.min.js" ></script>
	<script type="text/javascript" src="__TMPL__/public/assets/js/mobiscroll_003.js" ></script>
	<script type="text/javascript" src="__TMPL__/public/assets/js/js.js" ></script>
	<script>

		//判断当前选择时间是否小于是当前实际时间
		// function contrastTime(start) {
		// 	//var evalue = document.getElementById(start).value;
		// 	var dB = new Date(start.replace(/-/g, "/"));//获取当前选择日期
		// 	var d = new Date();
		// 	var str = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();//获取当前实际日期
		// 	if (Date.parse(str) > Date.parse(dB)) {//时间戳对比
		// 	       return 1;
		// 	} 
		// 	return 0;
		// }
		$(function(){

			var nowtime = "{:date('Y-m-d')}";
			var show = "{:date('Y-m-d')}";
			var timetype = $('#amOrpmText').html();
			$("#appDate").mobiscroll().date({
				theme: "android-ics",
				lang: "zh",
				display: 'bottom',
				selectType: 'week',
				dateFormat: 'yy-mm-dd', //返回结果格式化为年月格式
				//wheels:[], //设置此属性可以只显示年月，此处演示，就用下面的onBeforeShow方法,另外也可以用treelist去实现
				//onBeforeShow: function (inst) { inst.settings.wheels[0].length>2?inst.settings.wheels[0].pop():null; }, //弹掉“日”滚轮
				headerText: function(valueText) { //自定义弹出框头部格式
					array = valueText.split('-');
					return array[0] + "年" + array[1] + "月" + array[2] + "日";
				},
				onSelect: function(valueText, inst) {
					var showDay = valueText.split('-');
					var mydate=new Date( );
					var myddy=mydate.getDay();//获取存储当前日期
					var weekday=["周日","周一","周二","周三","周四","周五","周六"];
					
					show = showDay[0]+'-'+showDay[1]+'-'+showDay[2];
					if (Date.parse(nowtime) > Date.parse(valueText)) {
						alert("不能小于当前实际时间。");
						return false;
					}

					$.ajax({ 
							url: "{:url('indexCheck')}", 
							type:"POST",
							data: {
								sdate:show,
								timetype:timetype,
							},
							dataType:"json",
							success: function(data){
					    		var obj = data.msg;
					    		var kyhtml="";
					    		if (data.status == 0) {
					    			alert(data.msg);
					    			return false;
					    		}
					    		for (var i = 0; i < obj.length ; i++) {
					    			kyhtml += "<div class='rList div_float'>";
					    			if( i%3 == 0 || i==0 ){
					    				kyhtml += "<img src='__TMPL__/public/assets/images/y1.png' />";
					    			}else if( (i+2)%3 == 0 ){
					    				kyhtml += "<img src='__TMPL__/public/assets/images/y2.png' />";
					    			}else if( (i+1)%3 == 0 ){
					    				kyhtml += "<img src='__TMPL__/public/assets/images/y3.png' />";
					    			}
									kyhtml += "<P>"+obj[i].list_title+"</P>";
									kyhtml += "<P>（"+obj[i].list_subtitle+"）</P>";
									if( obj[i].book.status === 1 ){
					    				kyhtml += "<P class='state audit'>已预约</P>";
										kyhtml += "<p class='yd noYd'>预定</p>";
					    			}else if( obj[i].book.status === 0 ){
					    				kyhtml += "<P class='state audit'>待审核 </P>";
										kyhtml += "<p class='yd noYd'>预定</p>";
					    			}else{
					    				kyhtml += "<P class='state'>未预约</P>";
										if (timetype =="上午") {
					    					kyhtml += "<a href='/portal/meeting/add/id/"+ obj[i].id+"/timetype/1/sdate/"+show+".html'><p class='yd'>预定</p></a>";
					    				}else{
					    					kyhtml += "<a href='/portal/meeting/add/id/"+ obj[i].id+"/timetype/2/sdate/"+show+".html'><p class='yd'>预定</p></a>";
					    				}
					    			}
									kyhtml += "</div>";
					    		}
					    		$("#appDateText").html(showDay[1]+'-'+showDay[2]+'<span>'+weekday[myddy]+'</span>');
					    		$('.rCn').html(''); 
              					$('.rCn').html(kyhtml);
              					
					   		} ,
					   		error:function(){
					   			console.log("失败");
					   		}
					   	});
				}
			});

			$("#amOrpm").click(function() {
				var that = this;
				$("#sex-list").mobiscroll().treelist({
					theme: "android-ics",
					lang: "zh",
					display: 'bottom',
					headerText: '请您选择',
					onSelect: function(valueText) {
						var m = $(this).find("li").eq(valueText).html();
						
						timetype = m;
						$.ajax({ 
							url: "{:url('indexCheck')}", 
							type:"POST",
							data: {
								sdate:show,
								timetype:timetype,
							},
							dataType:"json",
							success: function(data){
					    		var obj = data.msg;
					    		var kyhtml="";
					    		if (data.status == 0) {
					    			alert(data.msg);
					    			return false;
					    		}
					    		for (var i = 0; i < obj.length ; i++) {
					    			kyhtml += "<div class='rList div_float'>";
					    			if( i%3 == 0 || i ==0){
					    				kyhtml += "<img src='__TMPL__/public/assets/images/y1.png' />";
					    			}else if( (i+2)%3 == 0 ){
					    				kyhtml += "<img src='__TMPL__/public/assets/images/y2.png' />";
					    			}else if( (i+1)%3 == 0 ){
					    				kyhtml += "<img src='__TMPL__/public/assets/images/y3.png' />";
					    			}
									kyhtml += "<P>"+obj[i].list_title+"</P>";
									kyhtml += "<P>（"+obj[i].list_subtitle+"）</P>";
									if( obj[i].book.status === 1 ){
					    				kyhtml += "<P class='state audit'>已预约</P>";
										kyhtml += "<p class='yd noYd'>预定</p>";
					    			}else if( obj[i].book.status === 0 ){
					    				kyhtml += "<P class='state audit'>待审核 </P>";
										kyhtml += "<p class='yd noYd'>预定</p>";
					    			}else{
					    				kyhtml += "<P class='state'>未预约</P>";
					    				if (timetype =="上午") {
					    					kyhtml += "<a href='/portal/meeting/add/id/"+ obj[i].id+"/timetype/1/sdate/"+show+".html'><p class='yd'>预定</p></a>";
					    				}else{
					    					kyhtml += "<a href='/portal/meeting/add/id/"+ obj[i].id+"/timetype/2/sdate/"+show+".html'><p class='yd'>预定</p></a>";
					    				}
										
					    			}
									kyhtml += "</div>";
					    		}
					    		$(that).val(m);
								$('#amOrpmText').html(m);
					    		$('.rCn').html(''); 
              					$('.rCn').html(kyhtml);
              					
					   		} ,
					   		error:function(){
					   			console.log("失败");
					   		}
					   	});
					}
				});
				
				$("input[id^=sex-list]").focus();
			});
		})
	</script>
	</body>
</html>
